﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Face_Recognition.Haar
{
    public class TreeNode
    {  
        private int rightNodeIndex = -1;
        private int leftNodeIndex = -1;

        public double Threshold { get; set; }

        public double LeftValue { get; set; }

        public double RightValue { get; set; }

        public int LeftNodeIndex {get; set;}

        public int RightNodeIndex {get; set;}


        /// <summary>
        ///   Gets the feature associated with this node.
        /// </summary>
        ///
        public Feature Feature { get; set; }

        /// <summary>
        ///   Constructs a new feature tree node.
        /// </summary>
        public TreeNode()
        {
        }

        /// <summary>
        ///   Constructs a new feature tree node.
        /// </summary>
        /// 
        public TreeNode(double threshold, double leftValue, double rightValue, params int[][] rectangles)
            : this(threshold, leftValue, rightValue, false, rectangles)
        {
        }

        /// <summary>
        ///   Constructs a new feature tree node.
        /// </summary>
        /// 
        public TreeNode(double threshold, double leftValue, double rightValue, bool tilted, params int[][] rectangles)
        {
            this.Feature = new Feature(tilted, rectangles);
            this.Threshold = threshold;
            this.LeftValue = leftValue;
            this.RightValue = rightValue;
        }

        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        /// 
        //public object Clone()
        //{
        //    TreeNode r = new TreeNode();

        //    r.Feature = (Feature)Feature.Clone();
        //    r.Threshold = Threshold;

        //    r.RightValue = RightValue;
        //    r.LeftValue = LeftValue;

        //    r.LeftNodeIndex = leftNodeIndex;
        //    r.RightNodeIndex = rightNodeIndex;

        //    return r;
        //}

    }
}
